Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

319
Vistas
"set: illegal option -" on one host but not the other

I've written a sh script in one of my ubuntu VMs which works fine, but when I try to run it in my other VMs, it does not work. Both VMs should be the same. With bash --version both VMs reply with:

GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

With lsb_release -a, both also reply:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:        14.04
Codename:       trusty

My security_steps.sh script looks like this:

#!/bin/sh

set -e

if ! [ -f svn_up_action.sh ]; then
  echo "svn_up_action.sh is missing. Please make sure it is in the same directory as this script."
  exit
fi

When I do: sudo sh security_steps.sh, the console errors with:

: not foundeps.sh: 6: security_steps.sh:
security_steps.sh: 7: set: Illegal option -

How can I figure out what's going on with the VM of the non-working shell? I feel like the shells are somehow different. I appreciate your help!

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

This almost certainly means your file has DOS newlines -- thus, hidden CR characters at the end.

Thus, set -e becomes set -e$'\r' (using bash-specific syntax to represent the CR character), which isn't a valid option.

This also explains the : not found, as a CR will reset the cursor to the beginning of the line, truncating an error message of the form sh: commandname: not found by making the commandname instead an operation that moves the cursor to the beginning of the line.

over 4 years ago · Santiago Trujillo Denunciar

0

I had *.sh file throwing me this while running it on Windows (via GitBash).

I've had to change line endings to UNIX/OSX format.

over 4 years ago · Santiago Trujillo Denunciar

0

In Windows:

choco install dos2unix
dos2unix file.sh

In Linux:

sudo apt install dos2unix
dos2unix file.sh

dos2unix converts the file to the Unix type.

After doing this, try to run the application again or the file.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda